#define UNICODE 1
#define _UNICODE 1

#include <windows.h>
#include <winioctl.h>
#include <winbase.h>
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
//#include <ntddchgr.h>

int main()
{
    
    HANDLE hDevice;               // handle to the drive to be examined 
    int x = 1;
    hDevice = CreateFile(TEXT("\\\\.\\COM3"),  // drive to open
                                      //\\\\.\\PhysicalDrive0
                    0,                // no access to the drive
                    FILE_SHARE_READ | // share mode
                    FILE_SHARE_WRITE, 
                    NULL,             // default security attributes
                    OPEN_EXISTING,    // disposition
                    0,                // file attributes
                    NULL);            // do not copy file attributes
                    
    if (hDevice == INVALID_HANDLE_VALUE)
    {
                printf("fail\n");
                system("pause");
                return (FALSE);
    }
    else
    {
        printf("Got it!\n");
    }
    /*
    typedef struct _MEDIA_SERIAL_NUMBER_DATA
    {
            ULONG SerialNumberLength;
            ULONG Result;
            ULONG Reserved[2];
            UCHAR SerialNumberData[];
    } MEDIA_SERIAL_NUMBER_DATA, *pmd;
    
    BOOL bResult;
    DWORD junk;
    */
/*    bResult = DeviceIoControl(hDevice,        // device to be queried
              IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER,  // operation to perform
              NULL, 0,                        // no input buffer
              NULL,             // output buffer
              0,                          // # bytes returned
              (LPOVERLAPPED) NULL);           // synchronous I/O
    
    printf("%d", bResult);
    */
    CloseHandle(hDevice);
    
    system("pause");
    

}
